from django.http import JsonResponse


class Code:
    """状态码"""
    Ok = 0
    Bad = 1


class ApiResponse(JsonResponse):
    """数据返回"""

    def __init__(self, code=Code.Ok, msg="", data=None, **kwargs):
        res = dict(
            code=code,
            msg=msg,
            data=data,
        )
        res.update(kwargs)
        super(ApiResponse, self).__init__(data=res)
